#include <bits/stdc++.h>
using namespace std;

int arr[25][25];
int main() {
    int n, m, x1, x2, y1, y2, ans = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            cin >> arr[i][j];
    cin >> x1 >> y1 >> x2 >> y2;
    for (int i = x1; i <= x2; ++i)
        for (int j = y1; j <= y2; ++j)
            ans += arr[i][j];
    cout << ans << endl;
    return 0;
}